package nc.bs.gl.report.impl;

import java.math.BigDecimal;
import java.sql.Types;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import com.ufida.report.anareport.base.BaseSearchTemplateCondition;

import nc.bs.dao.BaseDAO;
import nc.bs.gl.report.itf.CustomerBalanceReportService;
import nc.bs.gl.report.itf.WorkloadReportService;
import nc.jdbc.framework.processor.MapListProcessor;
import nc.pub.smart.context.SmartContext;
import nc.pub.smart.data.DataSet;
import nc.pub.smart.metadata.Field;
import nc.pub.smart.metadata.MetaData;
import nc.vo.am.common.util.CollectionUtils;
import nc.vo.pub.BusinessException;
import nc.vo.pub.lang.UFDate;
import nc.vo.pub.lang.UFDouble;
import nc.vo.pub.lang.UFLiteralDate;
import nc.vo.pubapp.AppContext;
import nccloud.dto.baseapp.querytree.dataformat.Condition;
import nccloud.dto.baseapp.querytree.dataformat.QueryTreeFormatVO;
import uap.lfw.bq.portal.base.StringUtils;

public class WorkloadReportServiceImpl implements WorkloadReportService {
	
	static String pk_group = "0001A210000000000JB9";

	String[] fields = new String[] { "deptname", "zmzrc", "mjzrc", "mzsxj", "mzs", "hlwmz",
			"ycxdrs", "jzs", "thsxj", "thmzs", "thhlwmz", "tjgzlxj", "grtj", "tztj", "qmgdcws",
			"sjkfcws", "zyzyzcrs", "rybrs", "sjkfzcrs", "cybrs", "cyzycws", "pjzyr", "cwsyl",
			"deptpk", "deptcode", "workdate", "pk_group","workdatebegin","workdateend", "mzrc"};
	String[] fieldCaptions = new String[] { "科室名称", "总门急诊人次", "门急诊人次", "门诊数小计", "门诊数", "互联网门诊", 
			"远程心电人数", "急诊数", "退号数小计", "退号门诊数", "退号互联网门诊", "体检工作量小计", "个人体检", "团体体检", "期末固定床位数",
			"实际开发床位数", "住院占用总床日数", "入院病人数", "实际开放总床日数", "出院病人数", "出院占用床位数", "平均住院日",
			"床位使用率", "科室主键", "科室编码", "统计日期", "集团主键", "开始日期", "截止日期", "门诊人次"};

	@Override
	public DataSet workloadDataProcess(SmartContext context) throws BusinessException {
		// 初始化元数据
		MetaData metadata = this.initMetaData();

		// 获取查询条件
		handelContext(context);
		
		String workdatebegin = ""; // 统计日期开始
		if (null != context.getAttribute("workdatebegin")) {
			workdatebegin = ((String) context.getAttribute("workdatebegin")).split(" ")[0];
		}
		String workdateend = ""; // 统计日期结束
		if (null != context.getAttribute("workdateend")) {
			workdateend = ((String) context.getAttribute("workdateend")).split(" ")[0];
		}

		// 查询HIS中间库中工作量相关数据
		List<Map<String, Object>> workData = queryData(workdatebegin, workdateend);
		if (CollectionUtils.isEmpty(workData))
		{
			return new DataSet(metadata, null);
		}
		
		// 查询档案对照中部门对照相关数据
		List<Map<String, Object>> deptData = getDeptInfo();
		if (CollectionUtils.isEmpty(deptData))
		{	
			return new DataSet(metadata, null);
		}

		// 处理数据
		Object[][] result = dataFilter(workData, deptData, workdatebegin, workdateend);

		return new DataSet(metadata, result);
	}

	/**
	 * 	初始化metadata
	 * @return
	 */
	private MetaData initMetaData() {
		Field[] FieldInfo = initField();
		MetaData md = new MetaData();
		for (int i = 0; i < fields.length; i++) {
			md.addField(FieldInfo[i]);
		}
		return md;
	}

	/**
	 * 	初始化返回字段
	 * @return
	 */
	private Field[] initField() {
		Field[] FieldInfo = new Field[fields.length];
		for (int i = 0; i < fields.length; i++) {
			Field filed = new Field();
			filed.setCaption(fieldCaptions[i]);
			filed.setDbColumnType(Types.VARCHAR);
			if (i == 5 || i == 7) { // 5,7对应编制金额，批复金额，金额是否需要调整字段类型，根据情况定
				filed.setDbColumnType(Types.DOUBLE);
			}
			filed.setDbColumnType(Types.VARCHAR);
			filed.setFldname(fields[i]);
			if (i == 2 || i == 6 || i == 8) {// 视情况而定
				filed.setPrecision(500);
			}
			FieldInfo[i] = filed;
		}
		return FieldInfo;
	}

	/**
	 * 	获取当前年
	 * @return
	 */
	public String getCurrentYear() {
		UFDate serverUFDate = AppContext.getInstance().getServerTime().getDate();
		UFLiteralDate serverDate = new UFLiteralDate(serverUFDate.toDate());
		String currentYear = serverDate.getYear() + "";
		return currentYear;
	}

	public void handelContext(SmartContext context) {
		BaseSearchTemplateCondition templateCondition = (BaseSearchTemplateCondition)context.getAttribute("FreeReport_All_Condition");
		if(null != templateCondition) {
			QueryTreeFormatVO conditionTree = templateCondition.getConditionTree();
			List<Condition> list = conditionTree.getQuerycondition().getConditions();
			for(Condition cond : list) {
				String file = cond.getField();
				String val = cond.getValue().getFirstvalue();
				if("between".equals(cond.getOprtype())) {
					val = cond.getValue().getFirstvalue()+","+cond.getValue().getSecondvalue();
				}
				context.setAttribute(file, val);
			}
		}
	}

	/**
	 * 	数据转换
	 * @param values
	 * @return
	 */
	public static String convertToInClause(String value) {
		if(StringUtils.isBlank(value)) {
			return "";
		}
		String[] values = value.split(",");

		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < values.length; i++) {
			sb.append('\'').append(values[i]).append('\'');
			if (i < values.length - 1) {
				sb.append(',');
			}
		}
		return sb.toString();
	}
	
	/**
	 * 	根据主键查询年度
	 * @param nyearpk  年度
	 * @return
	 * @throws BusinessException
	 */
	public List<Map<String, Object>> getDeptInfo() throws BusinessException {

        String sql = "SELECT hpf_dataconstruct_detail.destvaluecode deptcode, \n" +
                " 	   hpf_dataconstruct_detail.destvaluename deptname,  \n" +
                " 	   hpf_dataconstruct_detail.destvalue deptpk,  \n" +
                " 	   hpf_dataconstruct_detail.srcvaluecode hiscode \n" +
                "  FROM hpf_dataconstruct_detail \n" +
                " INNER JOIN hpf_dataconstruct on hpf_dataconstruct_detail.pk_dataconstructmaster = hpf_dataconstruct.pk_dataconstructmaster \n" +
                " INNER JOIN hpf_dept on hpf_dataconstruct_detail.srcvalue = hpf_dept.pk_dept  \n" +
                " WHERE hpf_dataconstruct.code = 'KSDZ002'  \n";

		List<Map<String, Object>> sqlResult = (List<Map<String, Object>>) this.getBaseDAO().executeQuery(sql,
				new MapListProcessor());
		if (CollectionUtils.isEmpty(sqlResult)) {
			return null;
		}

		return sqlResult;
	}

	/**
	 *
	 * 查询预算编制明细数据
	 *
	 * @param pk_org        财务组织
	 * @param nyear         预算年度
	 * @param pk_budgetdept 科室
	 * @return
	 * @throws BusinessException
	 */
	public List<Map<String, Object>> queryData(String wrokdatebegin, String wrokdateend)
			throws BusinessException {

		StringBuffer sql = new StringBuffer();
		sql.append("SELECT earningsdeptcode hiscode, \n");
		sql.append("       sum(def1) mzrc, \n");
		sql.append("       sum(def1 - def2) mzs, \n");
		sql.append("       sum(def2) hlwmz, \n");
		sql.append("       sum(def3) jzs, \n");
		sql.append("       sum(def4) thmzs, \n");
		sql.append("       sum(def5) thhlwmz, \n");
		sql.append("       sum(def6) grtj, \n");
		sql.append("       sum(def7) tztj, \n");
		sql.append("       sum(def8) qmgdcws, \n");
		sql.append("       sum(def9) sjkfcws, \n");
		sql.append("       sum(def10) zyzyzcrs, \n");
		sql.append("       sum(def11) rybrs, \n");
		sql.append("       sum(def12) sjkfzcrs, \n");
		sql.append("       sum(def13) cybrs, \n");
		sql.append("       sum(def14) cyzycws, \n");
		sql.append("       sum(def1) mzsxj, \n");
		sql.append("       sum(def4 + def5) thsxj, \n");
		sql.append("       sum(def6 + def7) tjgzlxj, \n");
		sql.append("       sum(def1 + def3 - def4 - def5) mjzrc, \n");
		sql.append("       sum(def1 + def3 - def4 - def5 + CASE WHEN def6 IS NULL THEN 0 ELSE TO_NUMBER(def6) END + CASE WHEN def7 IS NULL THEN 0 ELSE TO_NUMBER(def7) END) zmzrc, \n");
		sql.append("  CASE WHEN sum(def13) = 0 THEN 0 ELSE sum(def14)/sum(def13) END pjzyr, \n");
		sql.append("  CASE WHEN sum(def13) = 0 THEN 0 ELSE sum(def10)/sum(def12) END cwsyl \n");
		sql.append("  FROM hstf_mid_work_load_001 \n");
		sql.append(" WHERE 1 = 1 \n");
		sql.append("   AND earningsdeptcode !='4010009' \n");

		if (StringUtils.isNotBlank(wrokdatebegin)) {
			sql.append("   AND dbusdate >= '" + wrokdatebegin + "' \n");// 年度
		}
		if (StringUtils.isNotBlank(wrokdateend)) {
			sql.append("   AND dbusdate <= '" + wrokdateend + "' \n");// 月份
		}
		sql.append(" GROUP BY earningsdeptcode \n");
		sql.append(" ORDER BY earningsdeptcode ASC \n");

		List<Map<String, Object>> sqlResult = (List<Map<String, Object>>) this.getHisBaseDAO().executeQuery(sql.toString(),
				new MapListProcessor());
		if (CollectionUtils.isEmpty(sqlResult)) {
			return null;
		}

		return sqlResult;
	}

	/**
	 * 	根据主键查询年度
	 * @param nyearpk  年度
	 * @return
	 * @throws BusinessException
	 */
	public String getYear(String nyearpk) throws BusinessException {

		StringBuffer sql = new StringBuffer();
		sql.append("SELECT periodyear FROM  bd_accperiod  WHERE 1 = 1 \n");
		if (StringUtils.isNotBlank(nyearpk)) {
			sql.append("   AND pk_accperiod = '" + nyearpk + "' \n");// 年度主键
		}

		List<Map<String, Object>> sqlResult = (List<Map<String, Object>>) this.getBaseDAO().executeQuery(sql.toString(),
				new MapListProcessor());
		if (CollectionUtils.isEmpty(sqlResult)) {
			return null;
		}

		return (String) sqlResult.get(0).get("periodyear");
	}

	/**
	 * 	根据主键查询月份
	 * @param nmonthpk         月份
	 * @return
	 * @throws BusinessException
	 */
	public String getMonth(String nmonthpk) throws BusinessException {

		StringBuffer sql = new StringBuffer();
		sql.append("SELECT accperiodmth FROM  bd_accperiodmonth  WHERE 1 = 1 \n");
		if (StringUtils.isNotBlank(nmonthpk)) {
			sql.append("   AND pk_accperiodmonth = '" + nmonthpk + "' \n");// 年度主键
		}

		List<Map<String, Object>> sqlResult = (List<Map<String, Object>>) this.getBaseDAO().executeQuery(sql.toString(),
				new MapListProcessor());
		if (CollectionUtils.isEmpty(sqlResult)) {
			return null;
		}

		return (String) sqlResult.get(0).get("accperiodmth");
	}

	/**
	 * 	过滤数据
	 * @param datas
	 * @return
	 */
	private Object[][] dataFilter(List<Map<String, Object>> datas, List<Map<String, Object>> deptDatas, String workdatebegin, String workdateend) {
		Collection<Object[]> result = new ArrayList<Object[]>();

//		String formattedBeginDate = "";
//		String formattedEndDate = "";
//		// 格式化时间
//		DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");  
//		DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");  
//		if(StringUtils.isNotBlank(workdatebegin)) {
//	        // 解析字符串为 LocalDate  
//	        LocalDate beginDate = LocalDate.parse(workdatebegin, inputFormatter);
//	         // 格式化 LocalDate 为所需的字符串格式  
//	        formattedBeginDate = beginDate.format(outputFormatter);
//		}
//		if(StringUtils.isNotBlank(workdateend)) {
//	        // 解析字符串为 LocalDate  
//	        LocalDate endDate = LocalDate.parse(workdateend, inputFormatter);  
//	         // 格式化 LocalDate 为所需的字符串格式  
//	        formattedEndDate = endDate.format(outputFormatter);
//		}
        
		// 数据处理
		List<Map<String, Object>> tempList = new ArrayList<>();
		List<String> sortDeptCode = new ArrayList<String>();
		for (int i = 0; i < datas.size(); i++) {
			datas.get(i).put("pk_group", pk_group);
			datas.get(i).put("workdatebegin", workdatebegin);
			datas.get(i).put("workdateend", workdateend);
			if(null == datas.get(i).get("tjgzlxj")) {
				datas.get(i).put("tjgzlxj", 0);
			}
			if(null == datas.get(i).get("grtj")) {
				datas.get(i).put("grtj", 0);
			}
			if(null == datas.get(i).get("tztj")) {
				datas.get(i).put("tztj", 0);
			}
			for (int j = 0; j < deptDatas.size(); j++) {
				if(datas.get(i).get("hiscode").equals(deptDatas.get(j).get("hiscode"))) {
					datas.get(i).put("deptpk", deptDatas.get(j).get("deptpk"));
					datas.get(i).put("deptcode", deptDatas.get(j).get("deptcode"));
					datas.get(i).put("deptname", deptDatas.get(j).get("deptname"));
					sortDeptCode.add((String) datas.get(i).get("deptcode"));
					break;
				}
			}
			// 重复部门需要累加
			if(CollectionUtils.isEmpty(tempList)) {
				tempList.add(datas.get(i));
			}else {
				Boolean flag = true;
				for (int j = 0; j < tempList.size(); j++) {
					if(datas.get(i).get("deptcode").equals(tempList.get(j).get("deptcode"))) {
						// 累加计算部门工作量数据
						this.addDeptData(tempList.get(j), datas.get(i));
						flag = false;
					}
				}
				if(flag) {
					tempList.add(datas.get(i));
				}
			}
		}
		
		// 排序
		List<Map<String, Object>> resultList = new ArrayList<>();
		List<String> sortedList = sortDeptCode.stream().distinct().sorted().collect(Collectors.toList()); 
		for (int i = 0; i < sortedList.size(); i++) {
			for (int j = 0; j < tempList.size(); j++) {
				if(sortedList.get(i).equals(tempList.get(j).get("deptcode"))) {
					resultList.add(tempList.get(j));
				}
			}
		}
		
		// 替换
		// 计算天数获取期末数（除以天数）
		Integer dayRank = calday(workdatebegin, workdateend);
		Map<String, Object> sumData = new HashMap<>(); // 合计
		for (int i = 0; i < resultList.size(); i++) {
			String deptcode = resultList.get(i).get("deptcode").toString();
			String deptname = resultList.get(i).get("deptname").toString();
			Object qmgdcws = resultList.get(i).get("qmgdcws");
			Object sjkfcws = resultList.get(i).get("sjkfcws");
			
			if(deptname.contains("门诊")) {
				// 名称去掉门诊和编码去掉最后两位
				resultList.get(i).put("deptcode", deptcode.substring(0, deptcode.length() -2));
				resultList.get(i).put("deptname", deptname.replace("门诊", ""));
			}
			resultList.get(i).put("qmgdcws", "0");
			resultList.get(i).put("sjkfcws", "0");
			if(null != dayRank && 0 != dayRank) {
				if(null != qmgdcws && !UFDouble.ZERO_DBL.equals(getUFDouble(qmgdcws))) {
					// 期末数=期末总数/天数
					resultList.get(i).put("qmgdcws", getUFDouble(qmgdcws).div(new UFDouble(dayRank)));
				}
				if(null != sjkfcws && !UFDouble.ZERO_DBL.equals(getUFDouble(sjkfcws))) {
					// 实际开发数=实际开发数/天数
					resultList.get(i).put("sjkfcws", getUFDouble(sjkfcws).div(new UFDouble(dayRank)));
				}
			}
			sumData = addDeptData(sumData, resultList.get(i)); // 获取合计计算值
			Object[] rowdata = setDatas(resultList.get(i));
			result.add(rowdata);
		}
		
		// 计算合计
		sumData.put("pk_group", resultList.get(0).get("pk_group"));
		sumData.put("deptcode", "");
		sumData.put("deptname", "合计");
		sumData.put("workdatebegin", workdatebegin);
		sumData.put("workdateend", workdateend);
		sumData.put("pjzyr", "0");
		sumData.put("cwsyl", "0");
		Object cyzycws = sumData.get("cyzycws");
		Object cybrs = sumData.get("cybrs");
		Object sjkfzcrs = sumData.get("sjkfzcrs");
		Object zyzyzcrs = sumData.get("zyzyzcrs");
		if(null != cyzycws && !UFDouble.ZERO_DBL.equals(getUFDouble(cyzycws)) && null != cybrs && !UFDouble.ZERO_DBL.equals(getUFDouble(cybrs))) {
			sumData.put("pjzyr", getUFDouble(cyzycws).div(getUFDouble(cybrs)));
		}
		if(null != sjkfzcrs && !UFDouble.ZERO_DBL.equals(getUFDouble(sjkfzcrs)) && null != zyzyzcrs && !UFDouble.ZERO_DBL.equals(getUFDouble(zyzyzcrs))) {
			sumData.put("cwsyl", getUFDouble(zyzyzcrs).div(getUFDouble( sjkfzcrs)));
		}
		
		Object[] rowdata = setDatas(sumData);
		result.add(rowdata);

		return result.toArray(new Object[result.size() == 0 ? 1 : result.size()][]);
	}
	
	/**
	 * 	UFDouble格式转换
	 * @param amountObject
	 * @return
	 */
	public UFDouble getUFDouble(Object amountObject) {
		UFDouble amount = null;
		if(amountObject instanceof Integer) {
			amount = new UFDouble(Double.valueOf((Integer) amountObject)); //金额
		}else if(amountObject instanceof BigDecimal) {
			amount = new UFDouble(((BigDecimal) amountObject).doubleValue()); //金额
		}else {
			amount = new UFDouble(Double.valueOf("" + amountObject)); //金额
		}
		return amount;
	}
	
	
	/**
	 *	 根据开始日期和结束日期计算天数
	 * @param workdatebegin
	 * @param workdateend
	 * @return
	 */
	private Integer calday(String workdatebegin, String workdateend) {
		if(StringUtils.isBlank(workdatebegin) || StringUtils.isBlank(workdateend)) {
			return null;
		}
		// 截取字符串
		String[] beginDayStr = workdatebegin.split("-");
		String[] endDayStr = workdateend.split("-");
		LocalDate beginDate = LocalDate.of(Integer.valueOf(beginDayStr[0]), Integer.valueOf(beginDayStr[1]), Integer.valueOf(beginDayStr[2]));
		LocalDate endDate = LocalDate.of(Integer.valueOf(endDayStr[0]), Integer.valueOf(endDayStr[1]), Integer.valueOf(endDayStr[2]));
		// 计算天数
		Integer daysBetween = Integer.valueOf((int) ChronoUnit.DAYS.between(beginDate, endDate)) + 1;
		return daysBetween;
	}
	
	/**
	 * 	累加计算部门工作量数据
	 * @param oldData
	 * @param addData
	 * @return
	 */
	private Map<String, Object> addDeptData(Map<String, Object> oldData, Map<String, Object> addData) {
		oldData.put("zmzrc", addIsNullAmount(oldData.get("zmzrc"),addData.get("zmzrc")));
		oldData.put("mjzrc", addIsNullAmount(oldData.get("mjzrc"),addData.get("mjzrc")));
		oldData.put("mzsxj", addIsNullAmount(oldData.get("mzsxj"),addData.get("mzsxj")));
		oldData.put("mzs", addIsNullAmount(oldData.get("mzs"),addData.get("mzs")));
		oldData.put("hlwmz", addIsNullAmount(oldData.get("hlwmz"),addData.get("hlwmz")));
		oldData.put("ycxdrs", addIsNullAmount(oldData.get("ycxdrs"),addData.get("ycxdrs")));
		oldData.put("jzs", addIsNullAmount(oldData.get("jzs"),addData.get("jzs")));
		oldData.put("thsxj", addIsNullAmount(oldData.get("thsxj"),addData.get("thsxj")));
		oldData.put("thmzs", addIsNullAmount(oldData.get("thmzs"),addData.get("thmzs")));
		oldData.put("thhlwmz", addIsNullAmount(oldData.get("thhlwmz"),addData.get("thhlwmz")));
		oldData.put("tjgzlxj", addIsNullAmount(oldData.get("tjgzlxj"),addData.get("tjgzlxj")));
		oldData.put("grtj", addIsNullAmount(oldData.get("grtj"),addData.get("grtj")));
		oldData.put("tztj", addIsNullAmount(oldData.get("tztj"),addData.get("tztj")));
		oldData.put("qmgdcws", addIsNullAmount(oldData.get("qmgdcws"),addData.get("qmgdcws")));
		oldData.put("sjkfcws", addIsNullAmount(oldData.get("sjkfcws"),addData.get("sjkfcws")));
		oldData.put("zyzyzcrs", addIsNullAmount(oldData.get("zyzyzcrs"),addData.get("zyzyzcrs")));
		oldData.put("rybrs", addIsNullAmount(oldData.get("rybrs"),addData.get("rybrs")));
		oldData.put("sjkfzcrs", addIsNullAmount(oldData.get("sjkfzcrs"),addData.get("sjkfzcrs")));
		oldData.put("cybrs", addIsNullAmount(oldData.get("cybrs"),addData.get("cybrs")));
		oldData.put("cyzycws", addIsNullAmount(oldData.get("cyzycws"),addData.get("cyzycws")));
		oldData.put("pjzyr", addIsNullAmount(oldData.get("pjzyr"),addData.get("pjzyr")));
		oldData.put("cwsyl", addIsNullAmount(oldData.get("cwsyl"),addData.get("cwsyl")));
		oldData.put("mzrc", addIsNullAmount(oldData.get("mzrc"),addData.get("mzrc")));
		return oldData;
	}
	
	/**
	 * 	加法计算
	 * @param amount1
	 * @param amount2
	 * @return
	 */
	public UFDouble addIsNullAmount(Object amount1, Object amount2) {
		if(null == amount1) {
			amount1 = UFDouble.ZERO_DBL;
		}
		if(null == amount2) {
			amount2 = UFDouble.ZERO_DBL;
		}
		UFDouble amountDouble1 = getAmount(amount1);
		UFDouble amountDouble2 = getAmount(amount2);
		UFDouble amount = amountDouble1.add(amountDouble2);
		return amount;
	}
	
	/**
	 * 	UFDouble格式转换
	 * @param amountObject
	 * @return
	 */
	public UFDouble getAmount(Object amountObject) {
		UFDouble amount = null;
		if(amountObject instanceof Integer) {
			amount = new UFDouble(Double.valueOf((Integer) amountObject)); //金额
		}else if(amountObject instanceof BigDecimal) {
			amount = new UFDouble(((BigDecimal) amountObject).doubleValue()); //金额
		}else {
			amount = new UFDouble(Double.valueOf("" + amountObject)); //金额
		}
		return amount;
	}

	/**
	 * 组装返回数据
	 *
	 * @param data
	 * @return
	 */
	private Object[] setDatas(Map<String, Object> data) {
		Object[] rowdata = new Object[fields.length];
		rowdata[0] = data.get("deptname");
		rowdata[1] = data.get("zmzrc");
		rowdata[2] = data.get("mjzrc");
		rowdata[3] = data.get("mzsxj");
		rowdata[4] = data.get("mzs");
		rowdata[5] = data.get("hlwmz");
		rowdata[6] = data.get("ycxdrs");
		rowdata[7] = data.get("jzs");
		rowdata[8] = data.get("thsxj");
		rowdata[9] = data.get("thmzs");
		rowdata[10] = data.get("thhlwmz");
		rowdata[11] = data.get("tjgzlxj");
		rowdata[12] = data.get("grtj");
		rowdata[13] = data.get("tztj");
		rowdata[14] = data.get("qmgdcws");
		rowdata[15] = data.get("sjkfcws");
		rowdata[16] = data.get("zyzyzcrs");
		rowdata[17] = data.get("rybrs");
		rowdata[18] = data.get("sjkfzcrs");
		rowdata[19] = data.get("cybrs");
		rowdata[20] = data.get("cyzycws");
		rowdata[21] = data.get("pjzyr");
		rowdata[22] = data.get("cwsyl");
		rowdata[23] = data.get("deptpk");		
		rowdata[24] = data.get("deptcode");
		rowdata[25] = data.get("workdate");
		rowdata[26] = data.get("pk_group");
		rowdata[27] = data.get("workdatebegin");
		rowdata[28] = data.get("workdateend");
		rowdata[29] = data.get("mzrc");
		
		return rowdata;
	}

	private BaseDAO baseDAO;

	public BaseDAO getBaseDAO() {
		return baseDAO == null ? new BaseDAO() : baseDAO;
	}
	
	public BaseDAO getHisBaseDAO() {
		return baseDAO == null ? new BaseDAO("HISDATA") : baseDAO; //正式配置
	}


}
